import Vue from "vue";
import Router from "vue-router";
// import MainSite from '@/views/MainSite.vue';
// import ZtQualityInfo from '@/views/ZtQualityInfo.vue';
// import WorkList from '@/views/WorkList.vue';
// import ZtQualityConfig from "@/views/ZtQualityConfig.vue";
// import ZtFindCase from "@/views/ZtFindCase.vue";
// import ztLearnMethod from "@/views/ztLearnMethod.vue";
// import ZtReplyDepartment from "@/views/ZtReplyDepartment.vue";
// import ZtCategoryInfo from "../components/ZtCategoryInfo.vue";
// import Home from '../views/home/index.vue'
Vue.use(Router);
const originalPush = Router.prototype.push
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

let router = new Router({
  mode: "hash",
  routes: [
      ]
    },

  ],
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }; // 设置页面滚动到顶部
  }
});
let src = 'init';
router.afterEach((to, from) => {
  const iframe = window.parent.document.getElementById("main");
  if (iframe) {
    if (iframe.src.includes('?')) {
      if (iframe.src === src) {
        window.location.reload();
        src = null;
      }
    } else {
      iframe.src = `${iframe.src.split('?')[0]}?lastTime=${new Date().getTime()}`;
      if ('init' === src) {
        window.location.reload();
      }
      src = iframe.src;
    }
  }
  let banner = window.parent.document.getElementById('seeyonPortalHeader')
  let iframeHeight = window.parent.document.getElementById('custom-iframe')
  // console.log(banner,'banner')
  if (to.path == '/right') {
    // console.log(to,'满足')
    if (banner) {
      banner.style.display = 'block'
      iframeHeight.style.height = 'calc(100% - 50px)'
    }
  } else if (to.path !== '/right') {
    // console.log(to,'不满足')
    if (banner) {
      banner.style.display = 'none'
      iframeHeight.style.height = '100%'
    }
  }
});
export default router;
